<%--
  Created by IntelliJ IDEA.
  User: 123
  Date: 2020/5/31
  Time: 15:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/com.jsp"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div id="root">
    <card>
        <i-button type="primary" @click="add">添加用户</i-button>
    </card>
<i-table :columns="columns" :data="data"  height="400" Border stripe @on-selection-change="tableSelect=arguments[0]">
    <template slot-scope="{row,index}" slot="action">
        <i-Button type="info" size="large"  @click="update(row,index)">修改</i-Button>
        <i-Button type="error" size="large" @click="del(row,index)">删除</i-Button>
        <i-Button type="info" size="large" @click="del(row,index)">查看</i-Button>
    </template>
</i-table>
    <Modal v-model="modaladd" title="添加角色" @on-ok="doadd">
        <i-form :label="width=80">
            <Form-Item label="部门编号">
                <i-input v-model="plan.bmCode"size="large" placeholder="编号只能使用数字"></i-input>
            </Form-Item>
            <Form-Item label="部门名称">
                <i-input v-model="plan.bmName"size="large"></i-input>
            </Form-Item>

            <Form-Item label="备注">
                <i-input v-model="plan.bmBz"size="large"></i-input>
            </Form-Item>
        </i-form>
    </Modal>
</div>
</body>
<script>
    new Vue({
    el :"#root",
        data:{
        columns:[
            {title:"部门编号",key:"bmCode"},
            {title:"部门名称",key:"bmName"},
            {title:"加入时间",key:"bmData"},
            {title:"备注",key:"bmBz",width: 520},
            {title:"操作",slot:"action",width:250},
        ],
            data: [],
            modaladd:false,
            plan:{},

        },
        mounted(){
        this.getPlanList();
        },
        methods:{
            getPlanList(){
                axios.get(`${apath}/sys/plan/list`)
                .then(({data})=>{
                    this.data=data.result;
                })
            },
            add(){
                this.plan={},
                    this.modaladd=true;
            },
            doadd() {
                if (plan=null){
                    alert("数据不能为空,请重新添加")
                }else{
                    axios.post(`${apath}/sys/plan/add`,this.plan)
                        .then(({data})=>{
                            iview.Message.success({content:data.msg})
                            this.getPlanList();
                        })
                }
                }

        }
    })

</script>
</html>
